from typing import Optional, List
from pydantic import BaseModel, Field
from app.schemas.account import PaginationMeta, PaginationLinks, PaginationMetaWrapper


class CustomerBase(BaseModel):
    code: str = Field(..., description="客户编码")
    name: str = Field(..., description="客户名称")
    abbr_name: Optional[str] = Field(None, description="客户简称")
    account_id: str = Field(..., description="账套ID")
    status: int = Field(1, description="状态")


class CustomerCreate(CustomerBase):
    pass


class CustomerUpdate(BaseModel):
    code: Optional[str] = Field(None, description="客户编码")
    name: Optional[str] = Field(None, description="客户名称")
    abbr_name: Optional[str] = Field(None, description="客户简称")
    account_id: Optional[str] = Field(None, description="账套ID")
    status: Optional[int] = Field(None, description="状态")


class Customer(CustomerBase):
    id: str
    update_time: int

    class Config:
        orm_mode = True
        from_attributes = True


class CustomerListResponse(BaseModel):
    data: List[Customer] = Field(..., description="客户列表")
    meta: PaginationMetaWrapper = Field(..., description="分页元信息")
    links: PaginationLinks = Field(..., description="分页链接")